package pro.softzhang.algo.lc2400;

/**
 * https://leetcode.cn/problems/number-of-valid-clock-times/
 */
public class LC2437_NumberOfValidClockTimes {
    public static void main(String[] args) {
        String time = "?5:00";
        System.out.println(new Solution().countTime(time));
    }

    /**
     *
     */
    static
    class Solution {
        public int countTime(String time) {
            int hourCount = 0, minCount = 0;
            // 小时
            for (int h = 0; h < 24; h++) {
                int h1 = h / 10, h2 = h % 10;
                if ((time.charAt(0) == '?' || time.charAt(0) == h1 + '0') && (time.charAt(1) == '?' || time.charAt(1) == h2 + '0')) {
                    hourCount++;
                }
            }
            // 分钟
            for (int i = 0; i < 60; i++) {
                int m1 = i / 10, m2 = i % 10;
                if ((time.charAt(3) == '?' || time.charAt(3) == m1 + '0') && (time.charAt(4) == '?' || time.charAt(4) == m2 + '0')) {
                    minCount++;
                }
            }
            return hourCount * minCount;
        }
    }
}
